package impl.myjdkimpl;

import common.UserService;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;

import java.lang.reflect.Method;

/**
 * Created by chenjun on 2017/11/21.
 */
public class MyHandler implements MyInvocationHandler {
    private UserService userService;

    public  MyHandler(UserService service) {
        this.userService = service;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object result = null;

        before();
        result = method.invoke(this.userService,args);
        after();

        return  result;
    }

    public  void before(){

        System.out.println("---my handler before----");

    }

    public  void after(){
        System.out.println("---my handler after----");
        MethodVisitor methodVisitor;
    }
}
